package com.twu.biblioteca.actions;

import com.twu.biblioteca.exceptions.InvalidMenuError;

import java.util.ArrayList;

public class Actions extends ArrayList<BaseAction> {
    public BaseAction getAction(int index) throws InvalidMenuError {
        try {
            return super.get(index);
        } catch (IndexOutOfBoundsException exception) {
            throw new InvalidMenuError();
        }
    }

    public void print(){
        System.out.println("\n -- Biblioteca App --");
        for (int actionId = 0; actionId < size(); ++actionId){
            BaseAction action = get(actionId);
            System.out.println(actionId + ". " + action.actionName());
        }
        System.out.print("> ");
    }
}
